package com.caldremch.rxretrofit.api;


import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import okhttp3.OkHttpClient;

/**
 * Created by Caldremch on 2017-06-15 23:24
 */

public class BaseApiRetrofit {

    private final OkHttpClient mClient;

    public OkHttpClient getClient() {
        return mClient;
    }


    public BaseApiRetrofit() {

        OkHttpClient.Builder builder = new OkHttpClient.Builder();
        LoggerInterceptor loggerInterceptor = new LoggerInterceptor("tag");
        loggerInterceptor.setPrintLevel(LoggerInterceptor.Level.BODY);
        loggerInterceptor.setColorLevel(Level.INFO);
        builder.addInterceptor(loggerInterceptor);
        //设置超时
        builder.connectTimeout(10, TimeUnit.SECONDS);
        builder.readTimeout(20, TimeUnit.SECONDS);
        builder.writeTimeout(20, TimeUnit.SECONDS);
        //错误重连
        builder.retryOnConnectionFailure(true);
        mClient = builder
                .build();
    }



}
